home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / FUTILS / FBIOS.DOC next >
Text File  |  1989-02-19  |  7KB  |  200 lines

  1.                              /\ RKCP /\
  2.                              \/ RKCP \/
  3.  
  4. ********************************************************************
  5. ************************* FBIOS by Rex Kerr ************************
  6. ************************ Copyright (C) 1989 ************************
  7. ********************************************************************
  8.  
  9. This is a small unit for Turbo Pascal 5.0 written in assembly
  10. language.  I wrote it in assembly language for two reasons:
  11. 1) I wanted it as fast as I could have it
  12. 2) I wanted it as small as I could have it
  13.  
  14. So I wrote it in assembly language.  Programming in assembler,
  15. compared with programming in pascal, is tedious, boring, and
  16. "dangerous."  But it has advantages that cannot be overlooked.  It
  17. produces tiny code, and is far more flexible that Pascal.  I
  18. purposely haven't included any of the "dangerous" BIOS interrupts
  19. (like disk service) because they are too hard to test and debug
  20. (not to mention use!).  So here are 16 of the BIOS routines I use
  21. most:
  22.  
  23. ***
  24.  
  25. BiosPrintScr;
  26.  
  27. This simply does a PrtSc.  Nothing more, nothing less.
  28.  
  29. ***
  30.  
  31. BiosCurShape(start,stop : byte);
  32.  
  33. This sets the shape of the cursor.  Lines are numbered 0 to 7 on
  34. CGAs and 0 to 13 on monochrome.  The normal cursor is 6 and 7 (CGA)
  35. or 12 and 13 (monochrome).  You can make the cursor dissapear by
  36. setting start to 32.
  37.  
  38. ***
  39.  
  40. BiosGetCur(var start,stop : byte);
  41.  
  42. This gets the shape of the cursor.  See BiosCurShape above.
  43.  
  44. ***
  45.  
  46. BiosGotoxy(x,y : byte);
  47.  
  48. This positions the cursor just like TP's GotoXY does.  But BIOS
  49. always has the full screen as its window.  Therefore, I use GotoXY
  50. for window-relative gotos and BiosGotoXy for screen-relative gotos.
  51.  
  52. ***
  53.  
  54. BiosGetxy(var x,y : byte);
  55.  
  56. This gets the position of the cursor in screen coordinates.  See
  57. BiosGotoxy
  58.  
  59. ***
  60.  
  61. BiosScroll(lines : shortint; x,y,w,h : byte; attr : byte);
  62.  
  63. This lets you define a window with X,Y,W,H and scroll it up the
  64. number of lines specified.  To scroll down, set a negative number.
  65. Any new lines resulting from scrolling will be blank and in
  66. the text attributes of attr.  If you are using the CRT unit in your
  67. program, you can have the new attributes the same as the ones in TP
  68. by putting the CRT variable textattr in for the attr byte.
  69.  
  70. example:  BiosScroll(-2,1,1,80,25,textattr);  { Scrolls whole screen
  71.                                                 down 2 lines in current
  72.                                                 TP text attribute }
  73.  
  74. ***
  75.  
  76. BiosChar(ch : char; attr : byte);
  77.  
  78. This writes ch to the screen in attr at the current position of the
  79. cursor.  The cursor is NOT updated, and no characters are
  80. interpreted.  In other words, bioschar(^G,textattr) would write
  81. ASCII character #7 to the screen, whereas write(^G) would sound a
  82. short beep.
  83.  
  84. ***
  85.  
  86. BiosGetChar(var ch : char; var attr : byte);
  87.  
  88. This reads ch and attr from the screen at the current cursor
  89. position.  The cursor is not updated; see BiosChar.
  90.  
  91. ***
  92.  
  93. BiosPutPixel(colr : byte; x,y : word);
  94.  
  95. This writes a pixel of color colr to the screen at X,Y.  You must
  96. be in graphics mode.  I do not recommend using this, however!  It
  97. is both slower and less portable than the Turbo Graph unit.  But,
  98. it IS smaller, so if you are really really tight on space and only
  99. want to draw a few dots or lines (or other simple things), it might
  100. do.
  101.  
  102. ***
  103.  
  104. BiosGetPixel(x,y : word) : byte;
  105.  
  106. This function returns the color of the pixel at X,Y.  See
  107. BiosPutPixel.
  108.  
  109. ***
  110.  
  111. BiosEquip : word;
  112.  
  113. This returns the BIOS's equipment list.  Here's how to decode the
  114. word:
  115.  
  116. Bits in word     Use          To get them at the beginning of a word
  117.    15,14     # of printers      w := w shr 14;
  118.    12        Game I/O attached  w := w and $1000; w := w shr 12;
  119.  11,10,9     # of RS-232        w := w and $0E00; w := w shr 9;
  120.    7,6       # of disk drives   w := (w and $00C0) shr 6; inc(w);
  121.    5,4       Initial video mode w := (w and $0030) shr 4;
  122.    3,2       Amount of RAM      w := (w and $000C) shr 2; inc(w);
  123.                                 w := w shl 4;
  124.    0         Any disk drives?   w := w and $0001;
  125.  
  126. If bit 0 = 0 then there are NO disk drives; otherwise the number in
  127. bits 7,6 is right.  3,2 contains the amount of ram on the motherboard
  128. (whatever you want that for) in kbytes.  Bits 5,4 contain the
  129. startup video configuration.  1 = 40 by 25 CGA, 2 = 80 by 25 CGA,
  130. and 3 = 80 by 24 monochrome.  This is a complex result; for more
  131. information, you can look it up in any good book on advanced
  132. MS-DOS or in the BIOS Technical Reference manual.  (By the way,
  133. it is interrupt $11.)
  134.  
  135. ***
  136.  
  137. BiosReadKey : word;
  138.  
  139. This is not a duplicate of Turbo's ReadKey.  For one thing, you
  140. never have to read twice to get one key.  The low byte of the
  141. word is the ASCII code returned, and the high byte is the scan
  142. code returned.  There is a table of the scan codes on page 450
  143. of the TP5 Reference guide.  Some experimenting on your part may
  144. be necessary to get a better understanding of this function.
  145.  
  146. ***
  147.  
  148. BiosTestKey(var key : word) : boolean;
  149.  
  150. If there aren't any keys waiting to be processed, BiosTestKey will
  151. return false and leave key undefined.  If there is a key waiting to
  152. be processed, BiosTestKey will return true, and key will be set to
  153. the key waiting.  It will not be removed, however; you need to call
  154. BiosReadKey (or ReadKey) for that.
  155.  
  156. ***
  157.  
  158. BiosShiftStatus : byte;
  159.  
  160. This function returns the shift status byte of the computer.  Here
  161. is the bit map of the byte:
  162.        7 : Insert ON                 6 : CapsLock ON
  163.        5 : NumLock ON                4 : ScrollLock ON
  164.        3 : Alt DOWN                  2 : Ctrl DOWN
  165.        1 : Lft-Shft DOWN             0 : Rgt-Shft DOWN
  166. The byte is at location 0:$417 (in case you want to modify any
  167. of the 7-4 bits);
  168.  
  169. ***
  170.  
  171. BiosPrintChar(prn_num : byte; ch : char) : byte;
  172.  
  173. Prn_num is the number of the printer to use (0 to 2 is valid),
  174. and ch is the character to print.  It returns a byte contaning
  175. the printer status.  Here is a bit map of that byte:
  176.        7 : Not busy                  6 : Acknowledge
  177.        5 : Out of paper              4 : Selected
  178.        3 : I/O error                 2 : *UNUSED*
  179.        1 : *UNUSED*                  0 : Time out
  180. I'm not sure what all of the codes mean, but you can always seem
  181. to write to the printer when bits 7 and 4 are on.
  182.  
  183. ***
  184.  
  185. BiosPrintStatus(prn_num : byte) : byte;
  186.  
  187. This just returns the status byte of the specified printer
  188. (without printing a character).  It is good to call this before
  189. you print to see if you can or not.
  190.  
  191. ***
  192.  
  193. And that's it.  If I've left anything out, or if anything is too
  194. unclear, please contact me via EasyPlex or BPROGA's TP5 message
  195. section on CompuServe.
  196.  
  197. Rex Kerr  71550,3147
  198.  
  199.                              /\ RKCP /\
  200.                              \/ RKCP \/